package com.baomidou.springmvc.service.system.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.baomidou.springmvc.mapper.system.RoleMapper;
import com.baomidou.springmvc.model.system.Role;
import com.baomidou.springmvc.service.system.IRoleService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Role 表数据服务层接口实现类
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService {

    @Override
    public Page<Role> buildinSelectRolePage(Page<Role> page, String name) {
        page.setSearchCount(true); // 查询总记录数
        List<Role> userList = baseMapper.selectPage(
                page,
                new EntityWrapper<Role>().like("role_name", name)
        );
        return page.setRecords(userList);
    }

    @Override
    public Page<Role> selectRolePage(Page<Role> page, String name) {
        page.setSearchCount(true); // 查询总记录数
        return page.setRecords(baseMapper.selectRoleList(page, name));
    }

    @Override
    public Page<Map> selectMapList(Page<Map> page, String name) {
        page.setSearchCount(true); // 查询总记录数
        return page.setRecords(baseMapper.selectMapList(page, name));
    }
}